/*     */ package dm.jdbc.driver;
/*     */ 
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import dm.jdbc.innerData.DmdbBdta;
/*     */ import java.sql.SQLException;
/*     */ import java.util.ArrayList;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DmdbResultSetCache_v
/*     */   extends DmdbResultSetCache
/*     */ {
/*     */   byte[] rowbuf;
/*     */   private int rowidCol;
/*     */   ArrayList bdta_list;
/*  24 */   private int bdtaIndex = 0;
/*     */   DmdbBdta cur_bdta;
/*  26 */   private int start_off = 0;
/*     */   private int offset;
/*     */   
/*     */   public DmdbResultSetCache_v(DmdbStatement_bs stmt, DmdbColumn[] colsInfo, int rowidCol)
/*     */   {
/*  31 */     super(stmt, colsInfo);
/*  32 */     this.rowbuf = null;
/*  33 */     this.rowidCol = rowidCol;
/*     */   }
/*     */   
/*     */   public void fillBuffer(byte[] buffer, int len, int rows) throws SQLException
/*     */   {
/*  38 */     env_stmt_init_curbuf();
/*     */     
/*  40 */     this.rowbuf = buffer;
/*     */     
/*  42 */     this.rownum = rows;
/*     */     
/*  44 */     this.realLen = len;
/*     */     
/*  46 */     this.start_off = 0;
/*     */     
/*  48 */     if (rows > 0) {
/*  49 */       while (this.offset < this.start_off + this.realLen) {
/*  50 */         DmdbBdta tmp = new DmdbBdta(this.rowbuf, this.offset);
/*  51 */         this.bdta_list.add(tmp);
/*  52 */         this.offset += tmp.len;
/*     */       }
/*  54 */       this.bdtaIndex = 0;
/*  55 */       this.cur_bdta = ((DmdbBdta)this.bdta_list.get(this.bdtaIndex));
/*     */     }
/*     */   }
/*     */   
/*     */   public void fillBuffer2(byte[] buffer, int off, int len, int fetched_rows)
/*     */     throws SQLException
/*     */   {
/*  62 */     env_stmt_init_curbuf();
/*     */     
/*  64 */     this.rowbuf = buffer;
/*  65 */     this.rownum = fetched_rows;
/*  66 */     this.realLen = len;
/*  67 */     this.start_off = off;
/*  68 */     this.offset = this.start_off;
/*     */     
/*  70 */     if (fetched_rows > 0) {
/*  71 */       while (this.offset < this.start_off + this.realLen) {
/*  72 */         DmdbBdta tmp = new DmdbBdta(this.rowbuf, this.offset);
/*  73 */         this.bdta_list.add(tmp);
/*  74 */         this.offset += tmp.len;
/*     */       }
/*  76 */       this.bdtaIndex = 0;
/*  77 */       this.cur_bdta = ((DmdbBdta)this.bdta_list.get(this.bdtaIndex));
/*     */     }
/*     */   }
/*     */   
/*     */   private void env_stmt_init_curbuf()
/*     */   {
/*  83 */     this.rownum = 0;
/*  84 */     this.curpos = 0;
/*  85 */     this.offset = 0;
/*  86 */     this.cur_bdta = null;
/*  87 */     this.bdtaIndex = 0;
/*  88 */     this.bdta_list = new ArrayList();
/*     */   }
/*     */   
/*     */   public void addBuffer(byte[] buffer, int len, int rows) throws SQLException {
/*  92 */     byte[] tmp = new byte[this.realLen + this.start_off + len];
/*  93 */     System.arraycopy(this.rowbuf, 0, tmp, 0, this.realLen + this.start_off);
/*  94 */     System.arraycopy(buffer, 0, tmp, this.realLen + this.start_off, len);
/*     */     
/*  96 */     this.rowbuf = tmp;
/*  97 */     this.rownum += rows;
/*  98 */     this.realLen += len;
/*     */     
/* 100 */     if (rows > 0) {
/* 101 */       while (this.offset < this.start_off + this.realLen) {
/* 102 */         DmdbBdta bdta_tmp = new DmdbBdta(this.rowbuf, this.offset);
/* 103 */         this.bdta_list.add(bdta_tmp);
/* 104 */         this.offset += bdta_tmp.len;
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   public boolean next() throws SQLException
/*     */   {
/* 111 */     if (this.curpos >= this.rownum - 1) {
/* 112 */       return false;
/*     */     }
/*     */     
/* 115 */     if (!this.cur_bdta.next())
/*     */     {
/* 117 */       this.bdtaIndex += 1;
/* 118 */       this.cur_bdta = ((DmdbBdta)this.bdta_list.get(this.bdtaIndex));
/* 119 */       this.cur_bdta.absolute(0);
/*     */     }
/*     */     
/* 122 */     this.curpos += 1;
/*     */     
/* 124 */     return true;
/*     */   }
/*     */   
/*     */   public boolean previous() throws SQLException {
/* 128 */     if (this.curpos <= 0) {
/* 129 */       return false;
/*     */     }
/*     */     
/* 132 */     if (!this.cur_bdta.previous()) {
/* 133 */       this.bdtaIndex -= 1;
/* 134 */       this.cur_bdta = ((DmdbBdta)this.bdta_list.get(this.bdtaIndex));
/* 135 */       this.cur_bdta.absolute(this.cur_bdta.rownum - 1);
/*     */     }
/*     */     
/* 138 */     this.curpos -= 1;
/*     */     
/* 140 */     return true;
/*     */   }
/*     */   
/*     */   public boolean absolute(int position) throws SQLException {
/* 144 */     if (position < 0) {
/* 145 */       position = 0;
/*     */     }
/*     */     
/*     */ 
/* 149 */     if (position >= this.rownum) {
/* 150 */       position = this.rownum - 1;
/*     */     }
/*     */     
/* 153 */     if (position == 0) {
/* 154 */       this.bdtaIndex = 0;
/* 155 */       this.cur_bdta = ((DmdbBdta)this.bdta_list.get(this.bdtaIndex));
/* 156 */       this.cur_bdta.absolute(0);
/* 157 */     } else if (position == this.rownum - 1) {
/* 158 */       this.bdtaIndex = (this.bdta_list.size() - 1);
/* 159 */       this.cur_bdta = ((DmdbBdta)this.bdta_list.get(this.bdtaIndex));
/* 160 */       this.cur_bdta.absolute(this.cur_bdta.rownum - 1);
/*     */     } else {
/* 162 */       int rows = 0;
/* 163 */       for (int i = 0; i < this.bdta_list.size(); i++) {
/* 164 */         this.bdtaIndex = i;
/* 165 */         DmdbBdta tmp = (DmdbBdta)this.bdta_list.get(this.bdtaIndex);
/* 166 */         if (rows + tmp.rownum > position) {
/* 167 */           this.cur_bdta = tmp;
/* 168 */           this.cur_bdta.absolute(position - rows);
/* 169 */           break;
/*     */         }
/* 171 */         rows += tmp.rownum;
/*     */       }
/*     */     }
/* 174 */     this.curpos = position;
/*     */     
/* 176 */     return true;
/*     */   }
/*     */   
/*     */   public byte[] getBytes(short columnNo) throws SQLException {
/* 180 */     return this.cur_bdta.getBytes(columnNo);
/*     */   }
/*     */   
/*     */   public final Object clone() {
/* 184 */     DmdbResultSetCache_v rsCache = null;
/* 185 */     rsCache = (DmdbResultSetCache_v)super.clone();
/* 186 */     rsCache.statement = null;
/*     */     
/* 188 */     rsCache.curpos = 0;
/* 189 */     rsCache.bdtaIndex = 0;
/*     */     
/* 191 */     if ((this.bdta_list != null) && (this.bdta_list.size() > 0)) {
/* 192 */       rsCache.bdta_list = ((ArrayList)this.bdta_list.clone());
/* 193 */       this.cur_bdta = ((DmdbBdta)rsCache.bdta_list.get(0));
/*     */     }
/*     */     
/* 196 */     if (this.rowbuf != null) {
/* 197 */       rsCache.rowbuf = ((byte[])this.rowbuf.clone());
/*     */     }
/* 199 */     return rsCache;
/*     */   }
/*     */   
/*     */   long rec_get_rowid() {
/* 203 */     if (this.rowbuf == null) {
/*     */       try {
/* 205 */         DBError.throwSQLException(6021);
/*     */       } catch (SQLException e) {
/* 207 */         e.printStackTrace();
/* 208 */         return 0L;
/*     */       }
/*     */     }
/* 211 */     if (this.rowidCol != -1) {
/* 212 */       return this.cur_bdta.rec_get_rowid(this.rowidCol);
/*     */     }
/* 214 */     return -1L;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmdbResultSetCache_v.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */